<?php
	session_start();
	include '../../lib/common/dbRoutines.php';
	include '../../lib/dao/WordDao.php';
	
	$answer = "";
	
	//$word = iconv("UTF-8", "windows-1251", $_POST['word']);
	$word = $_POST['word'];
	$complexity = $_POST['complexity'];
	
	if(isset($_SESSION['user'])){
		
		$conn = getDbConnection();  
		$wordDao = new WordDao($conn); 
		
		$answer = $wordDao -> update_word($word, $complexity);
		if($answer==0){
			$answer = "The word was already deleted.";
		}
	}
	else{
		$answer = "error_in_moder_word - session is not set!";
	}
	
	echo $answer;
?>